package ddd6;
import java.io.File;
import java.io.IOException;

public class work1 {
    public static void main(String[] args) {
        String dirPath = "aaa";
        String fileName = "a.txt";
        File dir = new File(dirPath);
        if (!dir.exists()) {
            boolean dirCreated = dir.mkdir();
            if (dirCreated) {
                System.out.println("目录创建成功");
            } else {
                System.err.println("目录创建失败");
                return;
            }
        }
        File file = new File(dir, fileName);
        try {
            boolean fileCreated = file.createNewFile();
            if (fileCreated) {
                System.out.println("文件创建成功");
            } else {
                System.out.println("文件已存在");
            }
        } catch (IOException e) {
            System.err.println("创建文件时出错" + e.getMessage());
        }
    }
}